package com.xiaoniu.forum.service.impl;

import com.xiaoniu.forum.common.utils.CommonQueryVo;
import com.xiaoniu.forum.common.utils.QueryWrapperUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoniu.forum.common.utils.PageUtils;
import com.xiaoniu.forum.common.utils.Query;

import com.xiaoniu.forum.dao.TabbarItemDao;
import com.xiaoniu.forum.entity.TabbarItemEntity;
import com.xiaoniu.forum.service.TabbarItemService;
import org.springframework.util.StringUtils;


@Service("tabbarItemService")
public class TabbarItemServiceImpl extends ServiceImpl<TabbarItemDao, TabbarItemEntity> implements TabbarItemService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        QueryWrapper<TabbarItemEntity> queryWrapper = new QueryWrapper<>();
        IPage<TabbarItemEntity> page = this.page(new Query<TabbarItemEntity>().getPage(params),queryWrapper);
        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPage(CommonQueryVo queryVo) {
        QueryWrapper<TabbarItemEntity> queryWrapper=new QueryWrapper<>();
        if (!StringUtils.isEmpty(queryVo.getAnd()) || !StringUtils.isEmpty(queryVo.getOr())) {
            queryWrapper = QueryWrapperUtils.createQueryWrapper(queryVo, TabbarItemEntity.class);
        }
        IPage<TabbarItemEntity> page = this.page(new Query<TabbarItemEntity>().getPage(queryVo.getPageParams()),queryWrapper);
        return new PageUtils(page);
    }


}